package com.fengmi.controller;

import com.fengmi.dto.PageDTO;
import com.fengmi.entity.MallGoodsCat;
import com.fengmi.entity.ViewCatTemplate;
import com.fengmi.service.ICatTemplateService;
import com.fengmi.vo.CatCascadeVo;
import com.fengmi.vo.PageResultVO;
import com.fengmi.vo.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 作者：陈学虎
 * 时间：2021/7/10 0010 下午 2:45
 */
@RestController
@RequestMapping("/cat")
@CrossOrigin
@Api(description = "商品分类管理")
public class CatTemplateController {

    @Autowired
    private ICatTemplateService catTemplateService;

    @PostMapping("/findByParentId")
    @ApiOperation("根据分类节点id查询")
    public PageResultVO<ViewCatTemplate> findByParentId(@RequestBody PageDTO<ViewCatTemplate> pageDTO){
        return catTemplateService.findByParen(pageDTO);
    }

    @PostMapping("addCat")
    @ApiOperation("保存分类信息")
    public ResultVO addCat(@RequestBody MallGoodsCat mallGoodsCat) {
        return catTemplateService.addCat(mallGoodsCat);
    }

    @GetMapping("CatCascade")
    @ApiOperation("分类分级信息")
    public List<CatCascadeVo> findCatCascade(){
        return catTemplateService.findCatCascade();
    }
}
